package com.example.demo.mapper;

import java.text.MessageFormat;
import java.util.List;
import java.util.Map;

/**
 * Created by 86151 on 2018/12/24.
 */
public class DynamicJoin {
    public String zhuJieBatchQueryMaterials(Map map) {
        //接收到需要批量操作的集合
        List<Integer> legalPlantCodeList = (List<Integer>) map.get("list");
        //声明一个字符串，是stringbuider
        StringBuilder sb = new StringBuilder();
        sb.append("select * ");
        sb.append("from Material where id in (");
        MessageFormat mf = new MessageFormat("#'{'list[{0}]}");
        for (int i = 0; i < legalPlantCodeList.size(); i++) {
            sb.append(mf.format(new Object[]{i}));
            if (i < legalPlantCodeList.size() - 1) {
                sb.append(",");
            }
        }
        sb.append(")");
        return sb.toString();
    }
}
